<?php 

 header("Content-type: text/html; charset=utf-8");
require("conn.php");



$data = $_POST['user'];


$data=json_decode($data,true);


$didian = $data['didian'];
$pic1 = $data['pic'];
$shijian = $data['shijian'];
$act = $data['act'];
$uid = $data['uid'];
$username = $data['username'];

$shijian = (int)$shijian;
if ($act == "骑行" ) {
$jifen = ($shijian-5) * 1;
}
if ($act ==  "跑步" ) {
$jifen = ($shijian-5) * 2;
}
if ($act  == "个人球类运动（壁球）" || $act  == "游泳" ) {
$jifen = ($shijian-10) * 2;
}
if ($act == "健身或瑜伽类" ) {
$jifen = ($shijian-15) * 2;
}
if ($act ==  "对抗性球类运动" ) {
$jifen = ($shijian-20) * 3;
}
if ($act ==  "跳绳" ) {
$jifen = ($shijian-5) * 3;
}
if ($act ==  "跳舞" ) {
$jifen = ($shijian-20) * 3;

}

if ($jifen<0) {
echo  "500";
return false;
}else{

$kaishi = time();
$sql1="INSERT INTO pin(title,didian,uid,shichang,pic,kaishi,jifen,username) VALUES ('".$act."','".$didian."','".$uid."','".$shijian."','".$pic1."','".$kaishi."','".$jifen."','".$username."')";
$result=mysql_query($sql1,$conn);

if ($result) {
	echo  "1";
}else{
	echo  "no";

}
}

